/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit.ieproject.presentation;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.font.TextAttribute;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.Document;
import javax.swing.text.Highlighter;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import jvntokenizer.PennTokenizer;
import uit.ieproject.business.AddressBLO;
import uit.ieproject.business.GroupRegexBLO;
import uit.ieproject.business.PersonBLO;
import uit.ieproject.business.RegexBLO;
import uit.ieproject.crawler.MyControllerThread;
import uit.ieproject.crawler.NameControllerThread;
import uit.ieproject.entities.Person;
import uit.ieproject.entities.Regex;
import uit.ieproject.utilites.BackgroundPanel;
import uit.ieproject.utilites.ExtractUtil;
import uit.ieproject.utilites.ExtractionThread;
import uit.ieproject.utilites.FileUtil;
import uit.ieproject.utilites.ImageUtil;
import uit.ieproject.utilites.Info;
import uit.ieproject.utilites.StripedTableCellRenderer;
import uit.ieproject.utilites.TableUtil;
import uit.ieproject.utilites.TextpaneUtil;

/**
 *
 * @author Maivia
 */
public class MainFrame extends javax.swing.JFrame {

    private RegexBLO regexBLO = new RegexBLO();
    private PersonBLO personBLO = new PersonBLO();
    private GroupRegexBLO groupBLO = new GroupRegexBLO();
    public static AddressBLO addressBLO = new AddressBLO();
    private final String CARD_ANSWER_NAME = "cardAnswer";
    private final String CARD_EXTRACT_NAME = "cardExtract";
    private final String CARD_REGEX_NAME = "cardRegex";
    private final String CARD_DOWNLOAD_NAME = "cardDownload";
    private final String CARD_ABOUTUS_NAME = "cardAboutUs";
    private final String CARD_CREATEFILE_NAME = "cardCreateFile";
    private final String CARD_STATUS_NAME = "cardStatus";
    private final int IMG_WIDTH;
    private final int IMG_HEIGHT;
    private DefaultListModel fileListModel = new DefaultListModel();
    private String personNameAsk = null;
    private Long idSelectedRegex = 0L;
    private ArrayList<String> selectedGroups = new ArrayList<>();
    private String previousValidRegex;
    private int previousCaret;
    private boolean canDeleteRegex;
    private String selectedTextRegex;
    public static DefaultListModel crawlerListModel = new DefaultListModel();
    public static DefaultListModel downloadListModel = new DefaultListModel();
    private Thread extractThread;
    private Thread downloadFileThread;
    public String contentAddedFile = null;
    public String nameAddedFile = null;
    public String urlImageAddedFile = null;
    public int typeImgString = -1;
    //Author @Cong
    public static String URL;
    public static String paragraph;
    public static String title;
    public static String image;
    public static JList listNameChooser;
    public static Map<String, String> map;
    public static JList listDownloadName;
    public static ArrayList<String> arrlistLink;
    public static String directory;
    public static JButton crawlerNameButton;
    public static JButton downloadNameButton;
    public static JComboBox combobox;
    public static Thread crawlerThread;

    /**
     * Creates new form Frame
     */
    public MainFrame() {
        initComponents();

        //Set icon image:
        ImageIcon icon = new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/question48.png"));
        this.setIconImage(icon.getImage());

        Map<TextAttribute, Integer> fontAttributes = new HashMap<>();
        fontAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        Font boldUnderline = new Font("Dialog", Font.BOLD, 12).deriveFont(fontAttributes);
        lbDirStoreFile.setFont(boldUnderline);
        lbDirStoreImg.setFont(boldUnderline);
        lbManageAddress.setFont(boldUnderline);

        IMG_WIDTH = lbImage.getWidth();
        IMG_HEIGHT = lbImage.getHeight();

        //Select All textarea Question:
        taQuestion.selectAll();

        //Center frame
        this.setLocationRelativeTo(null);

        //Set Menu Border 
        Border loweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
        mnAnswer.setBorder(loweredBorder);

        //Format table
        TableUtil.formatTable(tbExtractedPerson);
        StripedTableCellRenderer.installInTable(tbExtractedPerson, Color.getHSBColor(1, 100, 217), null, null, null);

        //Show list extracted persons
        try {
            ArrayList<Person> persons = personBLO.getAllPerson();
            int numPersons = persons.size();
            if (numPersons > 0) {
                showListPerson(persons);
            } else {
                btDeletePerson.setEnabled(false);
                btViewPerson.setEnabled(false);
            }
        } catch (SQLException ex) {
        }

        crawlerNameButton = btGetNames;
        downloadNameButton = btDownloadFile;
        combobox = cbAddress;

        map = new HashMap<>();
        listNameChooser = listCrawlerName;
        listDownloadName = listChoseName;

        if (cbAddress.getModel().getSize() > 0) {
            btGetNames.setEnabled(true);
        } else {
            btGetNames.setEnabled(false);
        }

        showCbAddress(cbAddress);
        showCbNameRegex(cbNameAddRegex, cbTypeAddRegex);
    }

    private void resetPanelRegex() {
        //Show items of NameRegex combobox:
        showGroupName(cbNameGroup, cbTypeAddRegex, cbNameAddRegex);

        //Set default status for active checkbox and contentRegex textpane:
        chbStatusRegex.setSelected(true);
        TextpaneUtil.setForegroundForTextpane(tpContentRegex, Color.blue);
        tpContentRegex.setText("");
        //Remove all Attributes of Textpane check inpt:
        Highlighter highlighter = tpInputCheckText.getHighlighter();
        highlighter.removeAllHighlights();
        TextpaneUtil.removeAllAtrributes(tpInputCheckText);

        //Not in Edit mode and reset all selected groups & seleted text:
        idSelectedRegex = 0L;
        selectedTextRegex = null;
        selectedGroups.clear();

        //Cannot delete content regex in textpane:
        canDeleteRegex = false;

        //Set default status for buttons:
        btAddRegex.setEnabled(false);
        btEditRegex.setEnabled(false);
        btAddNameGroup.setEnabled(true);
        btDownloadFile.setEnabled(false);
    }

    private void resetPanelAddFile() {
        tfDirStoreImg.setForeground(Color.gray);
        tfDirStoreImg.setText("Đường dẫn hình ảnh...");

        contentAddedFile = null;

        urlImageAddedFile = null;

        lbAddFileWarning.setText("*Nội dung trống");
        lbAddFileWarning.setForeground(Color.red);

        btFileAdd.setEnabled(false);

        typeImgString = -1;
    }

    public void editModeWithRegex(Regex regex) {
        try {
            tpContentRegex.setText("");

            idSelectedRegex = regex.getId();
            String name = regex.getName();
            String type = regex.getType();
            String expression = regex.getExpression();
            int isActive = regex.getIsActive();
            cbNameAddRegex.setSelectedItem(name);
            cbTypeAddRegex.setSelectedItem(type);
            tpContentRegex.setText(expression);
            previousValidRegex = expression;

            //remove all highlighters
            Highlighter highlighter = tpInputCheckText.getHighlighter();
            highlighter.removeAllHighlights();
            TextpaneUtil.removeAllAtrributes(tpInputCheckText);
            TextpaneUtil.setHighlighterForCheckInput(expression, tpInputCheckText, Color.lightGray);

            if (isActive == 0) {
                chbStatusRegex.setSelected(false);
            } else {
                chbStatusRegex.setSelected(true);
            }

            String[] groups = groupBLO.getNameGroup(name, type).split(Info.SPLIT_GROUP_SYMBOL);
            selectedGroups.clear();
            selectedGroups.addAll(Arrays.asList(groups));
            cbNameGroup.removeAllItems();
            btEditRegex.setEnabled(true);
            btAddRegex.setEnabled(false);
            btAddNameGroup.setEnabled(false);
            setWarningText(lbWarning, "*Biểu thức chính quy hợp lệ", Color.blue);
            TextpaneUtil.setForegroundForTextpane(tpContentRegex, Color.blue);
        } catch (SQLException ex) {
        }
    }

    private void setStatusMenuClicked(JMenu menuClick, JMenu menu1, JMenu menu2, JMenu menu3, JMenu menu4) {
        Border loweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED);
        Border raiseBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED);
        menuClick.setBorder(loweredBorder);
        menu1.setBorder(raiseBorder);
        menu2.setBorder(raiseBorder);
        menu3.setBorder(raiseBorder);
        menu4.setBorder(raiseBorder);
    }

    private void showCardItem(String name, JPanel parent) {
        CardLayout cl = (CardLayout) parent.getLayout();
        cl.show(parent, name);
    }

    private void showListPerson(ArrayList<Person> persons) {
        try {
            DefaultTableModel model = (DefaultTableModel) tbExtractedPerson.getModel();
            model.setNumRows(0);
            int numPersons = persons.size();
            if (numPersons > 0) {
                for (int i = 0; i < numPersons; i++) {
                    model.addRow(new Object[]{i + 1, persons.get(i).getName(), persons.get(i).getId()});
                }
            }
        } catch (Exception ex) {
        }
    }

    private void showCbNameRegex(JComboBox cbName, JComboBox cbType) {
        cbName.removeAllItems();
        String selected = (String) cbType.getSelectedItem();
        try {
            ArrayList<String> names = groupBLO.getNameAtType(selected);
            int numNameRegex = names.size();
            for (int i = 0; i < numNameRegex; i++) {
                cbName.addItem(names.get(i));
            }
        } catch (SQLException ex) {
        }
    }

    private void showGroupName(JComboBox cbGroup, JComboBox cbType, JComboBox cbName) {
        try {
            cbGroup.removeAllItems();
            String typeSelected = (String) cbType.getSelectedItem();
            String nameSelected = (String) cbName.getSelectedItem();
            String groups = groupBLO.getNameGroup(nameSelected, typeSelected);
            String group_names[] = groups.split(Info.SPLIT_GROUP_SYMBOL);
            int numGroups = group_names.length;
            for (int i = 0; i < numGroups; i++) {
                cbGroup.addItem(group_names[i].trim());
            }
        } catch (SQLException ex) {
        }
    }

    public static void showCbAddress(JComboBox cbAddress) {
        cbAddress.removeAllItems();
        try {
            ArrayList<String> addresses = addressBLO.getAddressColumn();

            for (int i = 0; i < addresses.size(); i++) {
                cbAddress.addItem(addresses.get(i));
            }
        } catch (SQLException ex) {
        }

    }

    private void setStatusEditAddRegexButton(boolean status) {
        if (idSelectedRegex != 0) {     //Edit mode
            btEditRegex.setEnabled(status);
        } else {                        //Add mode
            btAddRegex.setEnabled(status);
        }
        btAddNameGroup.setEnabled(!status);
    }

    private void setWarningText(JLabel label, String text, Color color) {
        label.setForeground(color);
        label.setText(text);
    }

    private boolean isEmptyInput(String input) {
        boolean check = false;
        try {
            Pattern pattern;
            Matcher matcher;
            int count = 0;
            String[] temp = groupBLO.getNameGroup((String) cbNameAddRegex.getSelectedItem(), (String) cbTypeAddRegex.getSelectedItem()).split(Info.SPLIT_GROUP_SYMBOL);
            ArrayList<String> groups = new ArrayList<>();
            groups.addAll(Arrays.asList(temp));
            int numGroups = groups.size();
            for (int i = 0; i < numGroups; i++) {
                pattern = Pattern.compile("\\(\\?<" + groups.get(i) + ">\\)");
                matcher = pattern.matcher(input);
                while (matcher.find()) {
                    count++;
                }
            }
            if (count != 0) {
                check = true;
            }
        } catch (SQLException ex) {
        }
        return check;
    }

    private boolean isValidRegex(String regex) {
        try {
            Pattern.compile(regex);
            return true;
        } catch (PatternSyntaxException ex) {
            return false;
        }
    }

    private void checkInputRegex(String regex, JComboBox combo, JLabel label) {
        if (regex.isEmpty()) {
            setStatusEditAddRegexButton(false);
            setWarningText(label, "*Bạn chưa nhập biểu thức chính quy ", Color.red);
        } else if (isEmptyInput(regex)) {
            setStatusEditAddRegexButton(false);
            setWarningText(label, "*Bạn chưa nhập biểu thức chính quy đầy đủ vào các nhóm", Color.red);
        } else if (combo.getItemCount() != 0) {
            setStatusEditAddRegexButton(false);
            setWarningText(label, "*Chưa đủ nhóm yêu cầu", Color.red);
        } else if (!isValidRegex(regex)) {
            setStatusEditAddRegexButton(false);
            setWarningText(label, "*Biểu thức chính quy sai cấu trúc", Color.red);
        } else {
            setStatusEditAddRegexButton(true);
            setWarningText(label, "*Biểu thức chính quy hợp lệ", Color.blue);
        }

        //Final check
        if (combo.getItemCount() == 0) {
            btAddNameGroup.setEnabled(false);
        }
    }

    private int getGroupIndexFromSelectedRegex(String regex, String selectedText) {
        StringBuilder newRegex = new StringBuilder(regex);
        int length = regex.length();
        int increaselength = 0;
        //add symbol "\"
        for (int i = 0; i < length; i++) {
            if (regex.charAt(i) == '^' || regex.charAt(i) == '(' || regex.charAt(i) == ')' || regex.charAt(i) == '['
                    || regex.charAt(i) == '\\' || regex.charAt(i) == '{' || regex.charAt(i) == '+' || regex.charAt(i) == '.'
                    || regex.charAt(i) == '*' || regex.charAt(i) == '?' || regex.charAt(i) == '|') {
                newRegex.insert(i + increaselength, "\\");
                increaselength++;
            }
        }
        increaselength = 0;
        //re-set group "(" & ")"
        String temp = newRegex.toString();
        int newLength = temp.length();

        for (int i = 0; i < newLength; i++) {
            if (i == 0 && temp.charAt(i) == '\\' && temp.charAt(i + 1) == '(') {
                newRegex.insert(i + increaselength, "(");
                increaselength++;
            }
            if (i > 1 && temp.charAt(i - 2) != '\\' && temp.charAt(i - 1) == '\\'
                    && (temp.charAt(i) == '(' || temp.charAt(i) == ')')) {
                if (temp.charAt(i) == '(') {
                    newRegex.insert((i - 1) + increaselength, "(");
                }
                if (temp.charAt(i) == ')') {
                    newRegex.insert((i) + increaselength, ")");
                }
                increaselength++;
            }
        }
        Pattern pattern;
        Matcher matcher;
        pattern = Pattern.compile(newRegex.toString());
        matcher = pattern.matcher(regex);
        int groupCount = matcher.groupCount();
        while (matcher.find()) {
            for (int i = 1; i <= groupCount; i++) {
                String match = matcher.group(i);
                if (match.equals(selectedText)) {
                    return i;
                }
            }
        }
        return -1;
    }

    private void setAttrForExistHili(String regex, int startSelect, int endSelect, JTextPane textpane, Color color) {
        try {
            StyledDocument doc = textpane.getStyledDocument();
            SimpleAttributeSet attr = new SimpleAttributeSet();
            StyleConstants.setForeground(attr, color);
            attr.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
            String selectedText = "(" + regex.substring(startSelect, endSelect) + ")";
            regex = regex.substring(0, startSelect) + "(" + regex.substring(startSelect, endSelect) + ")"
                    + regex.substring(endSelect, regex.length());
            int groupSelected = getGroupIndexFromSelectedRegex(regex, selectedText);
            if (groupSelected != -1) {
                Pattern pattern = Pattern.compile(regex);
                Matcher matcher;
                Highlighter highlighter = textpane.getHighlighter();
                Highlighter.Highlight[] highlights = highlighter.getHighlights();
                int length = highlights.length;
                for (int i = 0; i < length; i++) {
                    int startHili = highlights[i].getStartOffset();
                    int endHili = highlights[i].getEndOffset();
                    String contentHighlight = textpane.getText(startHili, endHili - startHili);
                    matcher = pattern.matcher(contentHighlight);
                    while (matcher.find()) {
                        int start = matcher.start(groupSelected);
                        int end = matcher.end(groupSelected);
                        doc.setCharacterAttributes(startHili + start, end - start, attr, false);
                    }
                }
            }
        } catch (Exception ex) {
        }
    }

    private String getRegexInsideGroup(String content, String groupname) {
        String regex = null;
        Pattern pattern = Pattern.compile("\\(\\?<" + groupname + ">(?<select>((?!\\(\\?<).)*)\\)");
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            regex = matcher.group("select");
        }
        return regex;
    }

    private int[] checkMousePositionAtGroup(int pos, String content, ArrayList<String> selectedGroups) {
        int[] result = new int[2];
        Pattern pattern;
        Matcher matcher;
        int length = content.length();
        int numSelectedGroups = selectedGroups.size();
        if (numSelectedGroups > 0) {
            for (int i = 0; i < numSelectedGroups; i++) {
                String group = selectedGroups.get(i);
                pattern = Pattern.compile("^\\(\\?<" + group + ">((?!\\(\\?<).)*\\)$");
                boolean isIncrease = true;
                boolean isFinishLeft = false;
                boolean isStopRight = false;
                int left = pos;
                int right = pos;
                if (pos > 0 && pos <= length - 1) {
                    Character word = content.charAt(pos);
                    String temp = word.toString();
                    if (word == ')') {
                        result[1] = right + 1;
                        isStopRight = true;
                    }
                    while (left > 0 || right <= length - 1) {
                        if (isIncrease) {
                            if (!isStopRight) {
                                right++;
                                if (right <= length - 1) {
                                    Character rightWord = content.charAt(right);
                                    temp += rightWord.toString();
                                    if (rightWord == ')') {
                                        result[1] = right + 1;
                                        isStopRight = true;
                                    }
                                    matcher = pattern.matcher(temp);
                                    while (matcher.find()) {
                                        if (isValidRegex(temp) && isValidRegex(getRegexInsideGroup(temp, group))) {
                                            return result;
                                        }
                                    }
                                }
                            }
                            isIncrease = false;
                        } else {
                            if (!isFinishLeft) {
                                left--;
                                if (left >= 0) {
                                    Character leftWord = content.charAt(left);
                                    temp = leftWord.toString() + temp;
                                    if (temp.contains("(?<")) {
                                        result[0] = left;
                                        left = -1;
                                        isFinishLeft = true;
                                    }
                                    if (left == 0) {
                                        result[0] = left;
                                        break;
                                    }
                                    matcher = pattern.matcher(temp);
                                    while (matcher.find()) {
                                        if (isValidRegex(temp) && isValidRegex(getRegexInsideGroup(temp, group))) {
                                            return result;
                                        }
                                    }
                                }
                            }
                            isIncrease = true;
                        }
                        if (isStopRight && isFinishLeft) {
                            isStopRight = false;
                        }
                    }
                }
            }
        }
        return null;
    }

    private ArrayList<String> getGroupsCanDeleteWhenSelect(JComboBox combo, String regex) {
        ArrayList<String> groups = new ArrayList<>();
        Pattern pattern;
        Matcher matcher;
        int currentExistGroup = combo.getItemCount();
        if (currentExistGroup > 0) {
            for (int i = 0; i < currentExistGroup; i++) {
                String group = (String) combo.getItemAt(i);
                pattern = Pattern.compile("\\(\\?<" + group + ">(.*?)\\)");
                matcher = pattern.matcher(regex);
                while (matcher.find()) {
                    groups.add(group);
                    break;
                }
            }
        }
        if (groups.size() > 0) {
            return groups;
        } else {
            return null;
        }
    }

    private String getValidDeleteGroupName(String content, ArrayList<String> selectedGroup) {
        String result = null;
        String groupname;
        Pattern pattern;
        Matcher matcher;
        int numSelectedGroup = selectedGroup.size();
        for (int i = 0; i < numSelectedGroup; i++) {
            groupname = selectedGroup.get(i);
            pattern = Pattern.compile("^\\(\\?<" + groupname + ">((?!\\(\\?<).)*?\\)$");
            matcher = pattern.matcher(content);
            while (matcher.find()) {
                result = groupname;
                break;
            }
        }
        return result;
    }

    private String getContentInsideGroup(String group) {
        int index = 0;
        while (group.charAt(index) != '>') {
            group = group.substring(1, group.length());
        }
        if (group.charAt(index) == '>') {
            group = group.substring(1, group.length());
        }
        group = group.substring(index, group.length() - 1);
        return group;
    }

    private boolean checkValidNumOfSelectedGroup(String content, ArrayList<String> selectedGroup) {
        //Check group
        String groupname;
        Pattern pattern;
        Matcher matcher;
        int groupCount = 0;
        int numGroups = selectedGroup.size();
        for (int i = 0; i < numGroups; i++) {
            groupname = selectedGroup.get(i);
            pattern = Pattern.compile("\\(\\?<" + groupname + ">((?!\\(\\?<).)*?\\)");
            matcher = pattern.matcher(content);
            while (matcher.find()) {
                groupCount++;
                break;
            }
        }
        if (groupCount == numGroups) {
            return true;
        } else {
            return false;
        }
    }

    private void searchList(String keyword, JList list) {
        DefaultListModel model = (DefaultListModel) list.getModel();
        int replaceIndex = 0;
        String selectedItem;
        int numItems = model.size();
        for (int i = 0; i < numItems; i++) {
            selectedItem = (String) model.getElementAt(i);
            if (selectedItem.toLowerCase().contains(keyword.toLowerCase())) {
                model.set(i, (String) model.getElementAt(replaceIndex));
                model.set(replaceIndex, selectedItem);
                replaceIndex++;
            }
        }
        list.ensureIndexIsVisible(0);
    }

    private int checkImgStrIsDirOrUrl(String img) {  //-1:Invalid    0:URL   1:Dir
        Pattern urlCheckPattern = Pattern.compile("www\\..*?\\.");
        Pattern dirCheckPattern = Pattern.compile("[a-zA-Z]:\\.*");

        Matcher matcher = urlCheckPattern.matcher(img);
        while (matcher.find()) {
            return 0;
        }
        matcher.usePattern(dirCheckPattern);
        while (matcher.find()) {
            return 1;
        }
        return -1;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        panelGeneral = new javax.swing.JPanel();
        panelParent = new javax.swing.JPanel();
        panelAnswer = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taQuestion = new javax.swing.JTextArea();
        btAnswer = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btDetail = new javax.swing.JButton();
        lbImage = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        taAnswer = new javax.swing.JTextArea();
        panelExtract = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        btExtract = new javax.swing.JButton();
        jPanel15 = new javax.swing.JPanel();
        btChooseFiles = new javax.swing.JButton();
        btViewFiles = new javax.swing.JButton();
        btDeleteFiles = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        listFiles = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbExtractedPerson = new javax.swing.JTable();
        tfSearchPerson = new javax.swing.JTextField();
        btViewPerson = new javax.swing.JButton();
        btDeletePerson = new javax.swing.JButton();
        panelCard = new javax.swing.JPanel();
        panelCreateFile = new javax.swing.JPanel();
        btFileAdd = new javax.swing.JButton();
        btFileReset = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        tfDirStoreFile = new javax.swing.JTextField();
        tfDirStoreImg = new javax.swing.JTextField();
        lbDirStoreFile = new javax.swing.JLabel();
        lbDirStoreImg = new javax.swing.JLabel();
        btFileContent = new javax.swing.JButton();
        lbAddFileWarning = new javax.swing.JLabel();
        panelStatus = new javax.swing.JPanel();
        pbStatus = new javax.swing.JProgressBar();
        jScrollPane4 = new javax.swing.JScrollPane();
        tpStatus = new javax.swing.JTextPane();
        lbExtractImg = new javax.swing.JLabel();
        lbExtractName = new javax.swing.JLabel();
        rbCreateFile = new javax.swing.JRadioButton();
        rbStatus = new javax.swing.JRadioButton();
        panelRegex = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        cbTypeAddRegex = new javax.swing.JComboBox();
        cbNameGroup = new javax.swing.JComboBox();
        jScrollPane5 = new javax.swing.JScrollPane();
        tpContentRegex = new javax.swing.JTextPane();
        lbWarning = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        cbNameAddRegex = new javax.swing.JComboBox();
        btAddNameGroup = new javax.swing.JButton();
        chbStatusRegex = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        tpInputCheckText = new javax.swing.JTextPane();
        jPanel8 = new javax.swing.JPanel();
        btAddRegex = new javax.swing.JButton();
        btEditRegex = new javax.swing.JButton();
        btListRegex = new javax.swing.JButton();
        btReset = new javax.swing.JButton();
        panelDownload = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        cbAddress = new javax.swing.JComboBox();
        btGetNames = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        listCrawlerName = new javax.swing.JList();
        tsCrawlerSearch = new javax.swing.JTextField();
        jScrollPane8 = new javax.swing.JScrollPane();
        listChoseName = new javax.swing.JList();
        tfChoseSearch = new javax.swing.JTextField();
        btRight = new javax.swing.JButton();
        btLeft = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        tfPath = new javax.swing.JTextField();
        btFolderChooser = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        btDownloadFile = new javax.swing.JButton();
        lbManageAddress = new javax.swing.JLabel();
        panelAboutUs = new javax.swing.JPanel();
        panelImageBackgroup = new BackgroundPanel("/uit/ieproject/images/BACKGROUND2.jpg");
        jScrollPane9 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        mbarMain = new javax.swing.JMenuBar();
        mnAnswer = new javax.swing.JMenu();
        mnExtract = new javax.swing.JMenu();
        mnRegex = new javax.swing.JMenu();
        mnDownload = new javax.swing.JMenu();
        mnAboutUs = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Rút trích thông tin");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        panelParent.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        panelParent.setLayout(new java.awt.CardLayout());

        jLabel1.setText("Câu hỏi");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        taQuestion.setColumns(20);
        taQuestion.setForeground(java.awt.Color.gray);
        taQuestion.setRows(5);
        taQuestion.setText("Nhập câu hỏi vào đây.....");
        taQuestion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                taQuestionMousePressed(evt);
            }
        });
        taQuestion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                taQuestionKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(taQuestion);
        taQuestion.setLineWrap(true);
        taQuestion.setWrapStyleWord(true);

        btAnswer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/send.png"))); // NOI18N
        btAnswer.setText("Trả lời");
        btAnswer.setEnabled(false);
        btAnswer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAnswerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(btAnswer, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btAnswer)
                .addContainerGap())
        );

        jLabel2.setText("Trả lời");

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        btDetail.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/list.png"))); // NOI18N
        btDetail.setText("Xem chi tiết");
        btDetail.setEnabled(false);
        btDetail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDetailActionPerformed(evt);
            }
        });

        lbImage.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        taAnswer.setEditable(false);
        taAnswer.setColumns(20);
        taAnswer.setRows(5);
        jScrollPane10.setViewportView(taAnswer);
        taAnswer.setLineWrap(true);
        taAnswer.setWrapStyleWord(true);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btDetail, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                    .addComponent(lbImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(lbImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout panelAnswerLayout = new javax.swing.GroupLayout(panelAnswer);
        panelAnswer.setLayout(panelAnswerLayout);
        panelAnswerLayout.setHorizontalGroup(
            panelAnswerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAnswerLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAnswerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(panelAnswerLayout.createSequentialGroup()
                        .addGroup(panelAnswerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelAnswerLayout.setVerticalGroup(
            panelAnswerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAnswerLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(12, 12, 12)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        panelParent.add(panelAnswer, "cardAnswer");

        jLabel3.setText("Tập tin rút trích");

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        jPanel13.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        btExtract.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/extract.png"))); // NOI18N
        btExtract.setText("Rút trích");
        btExtract.setEnabled(false);
        btExtract.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExtractActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btExtract, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btExtract)
                .addContainerGap())
        );

        jPanel15.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, java.awt.Color.white, null));

        btChooseFiles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/file.png"))); // NOI18N
        btChooseFiles.setText("Chọn tập tin");
        btChooseFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btChooseFilesActionPerformed(evt);
            }
        });

        btViewFiles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/view.png"))); // NOI18N
        btViewFiles.setText("Xem tập tin");
        btViewFiles.setEnabled(false);
        btViewFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewFilesActionPerformed(evt);
            }
        });

        btDeleteFiles.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/Remove24.png"))); // NOI18N
        btDeleteFiles.setText("Xóa tập tin  ");
        btDeleteFiles.setEnabled(false);
        btDeleteFiles.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteFilesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btChooseFiles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btViewFiles, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btDeleteFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btChooseFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btViewFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btDeleteFiles, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        listFiles.setModel(fileListModel);
        listFiles.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                listFilesMousePressed(evt);
            }
        });
        jScrollPane2.setViewportView(listFiles);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2))
                .addContainerGap())
        );

        jLabel4.setText("Nhân vật rút trích");

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        tbExtractedPerson.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "STT", "Tên nhân vật", "Mã"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbExtractedPerson.setGridColor(new java.awt.Color(153, 204, 255));
        tbExtractedPerson.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tbExtractedPersonMousePressed(evt);
            }
        });
        jScrollPane3.setViewportView(tbExtractedPerson);
        tbExtractedPerson.getColumnModel().getColumn(0).setMinWidth(40);
        tbExtractedPerson.getColumnModel().getColumn(0).setPreferredWidth(40);
        tbExtractedPerson.getColumnModel().getColumn(0).setMaxWidth(40);
        tbExtractedPerson.getColumnModel().getColumn(2).setMinWidth(0);
        tbExtractedPerson.getColumnModel().getColumn(2).setPreferredWidth(0);
        tbExtractedPerson.getColumnModel().getColumn(2).setMaxWidth(0);

        tfSearchPerson.setForeground(java.awt.Color.gray);
        tfSearchPerson.setText("Tìm kiếm theo tên...");
        tfSearchPerson.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tfSearchPersonMousePressed(evt);
            }
        });
        tfSearchPerson.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfSearchPersonKeyReleased(evt);
            }
        });

        btViewPerson.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/person.png"))); // NOI18N
        btViewPerson.setText("Xem nhân vật");
        btViewPerson.setEnabled(false);
        btViewPerson.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btViewPersonActionPerformed(evt);
            }
        });

        btDeletePerson.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/delete.gif"))); // NOI18N
        btDeletePerson.setText("Xóa nhân vật");
        btDeletePerson.setEnabled(false);
        btDeletePerson.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeletePersonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tfSearchPerson)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(btViewPerson, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btDeletePerson)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tfSearchPerson, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btViewPerson, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btDeletePerson, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        panelCard.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        panelCard.setLayout(new java.awt.CardLayout());

        btFileAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/up24.png"))); // NOI18N
        btFileAdd.setText("Thêm mới");
        btFileAdd.setEnabled(false);
        btFileAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileAddActionPerformed(evt);
            }
        });

        btFileReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/refresh.png"))); // NOI18N
        btFileReset.setText("Làm mới");
        btFileReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileResetActionPerformed(evt);
            }
        });

        jPanel7.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        tfDirStoreFile.setEditable(false);
        tfDirStoreFile.setForeground(java.awt.Color.gray);
        tfDirStoreFile.setText("Đường dẫn lưu...");

        tfDirStoreImg.setForeground(java.awt.Color.gray);
        tfDirStoreImg.setText("Đường dẫn hình ảnh...");
        tfDirStoreImg.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tfDirStoreImgMousePressed(evt);
            }
        });
        tfDirStoreImg.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfDirStoreImgKeyReleased(evt);
            }
        });

        lbDirStoreFile.setForeground(java.awt.Color.blue);
        lbDirStoreFile.setText("Chọn");
        lbDirStoreFile.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbDirStoreFile.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lbDirStoreFileMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lbDirStoreFileMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                lbDirStoreFileMousePressed(evt);
            }
        });

        lbDirStoreImg.setForeground(java.awt.Color.blue);
        lbDirStoreImg.setText("Chọn");
        lbDirStoreImg.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbDirStoreImg.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lbDirStoreImgMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lbDirStoreImgMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                lbDirStoreImgMousePressed(evt);
            }
        });

        btFileContent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/detail.png"))); // NOI18N
        btFileContent.setText("Nội dung văn bản");
        btFileContent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFileContentActionPerformed(evt);
            }
        });

        lbAddFileWarning.setForeground(new java.awt.Color(255, 51, 51));
        lbAddFileWarning.setText("*Nội dung trống");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(lbAddFileWarning, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addComponent(btFileContent))
                    .addComponent(tfDirStoreImg)
                    .addComponent(tfDirStoreFile))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbDirStoreFile, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbDirStoreImg, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfDirStoreFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirStoreFile, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfDirStoreImg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbDirStoreImg))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btFileContent, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE)
                    .addComponent(lbAddFileWarning))
                .addContainerGap())
        );

        javax.swing.GroupLayout panelCreateFileLayout = new javax.swing.GroupLayout(panelCreateFile);
        panelCreateFile.setLayout(panelCreateFileLayout);
        panelCreateFileLayout.setHorizontalGroup(
            panelCreateFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCreateFileLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelCreateFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addGroup(panelCreateFileLayout.createSequentialGroup()
                        .addComponent(btFileReset, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btFileAdd))
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelCreateFileLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btFileAdd, btFileReset});

        panelCreateFileLayout.setVerticalGroup(
            panelCreateFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCreateFileLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCreateFileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btFileAdd)
                    .addComponent(btFileReset))
                .addGap(12, 12, 12)
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panelCreateFileLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btFileAdd, btFileReset});

        panelCard.add(panelCreateFile, "cardCreateFile");

        pbStatus.setStringPainted(true);

        jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        tpStatus.setEditable(false);
        tpStatus.setPreferredSize(new java.awt.Dimension(289, 22));
        jScrollPane4.setViewportView(tpStatus);

        lbExtractImg.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        lbExtractName.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbExtractName.setText("Tên nhân vật");
        lbExtractName.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        javax.swing.GroupLayout panelStatusLayout = new javax.swing.GroupLayout(panelStatus);
        panelStatus.setLayout(panelStatusLayout);
        panelStatusLayout.setHorizontalGroup(
            panelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelStatusLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pbStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbExtractImg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbExtractName, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
                .addContainerGap())
        );
        panelStatusLayout.setVerticalGroup(
            panelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelStatusLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelStatusLayout.createSequentialGroup()
                        .addComponent(pbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
                    .addGroup(panelStatusLayout.createSequentialGroup()
                        .addComponent(lbExtractImg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lbExtractName)))
                .addContainerGap())
        );

        panelCard.add(panelStatus, "cardStatus");

        buttonGroup1.add(rbCreateFile);
        rbCreateFile.setSelected(true);
        rbCreateFile.setText("Tạo tập tin");
        rbCreateFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbCreateFileActionPerformed(evt);
            }
        });

        buttonGroup1.add(rbStatus);
        rbStatus.setText("Trạng thái rút trích");
        rbStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbStatusActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelExtractLayout = new javax.swing.GroupLayout(panelExtract);
        panelExtract.setLayout(panelExtractLayout);
        panelExtractLayout.setHorizontalGroup(
            panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelExtractLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(panelExtractLayout.createSequentialGroup()
                        .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(panelExtractLayout.createSequentialGroup()
                                .addComponent(rbCreateFile)
                                .addGap(18, 18, 18)
                                .addComponent(rbStatus)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        panelExtractLayout.setVerticalGroup(
            panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelExtractLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelExtractLayout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addGroup(panelExtractLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rbCreateFile)
                            .addComponent(rbStatus))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panelCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelParent.add(panelExtract, "cardExtract");

        jLabel8.setText("Quản lý biểu thức chính quy");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        jLabel9.setText("Loại");

        jLabel10.setText("Tên");

        jLabel11.setText("Biểu thức");

        cbTypeAddRegex.addItem(Info.QA_TYPE);
        cbTypeAddRegex.addItem(Info.EXTRACT_TYPE);
        cbTypeAddRegex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbTypeAddRegexActionPerformed(evt);
            }
        });

        tpContentRegex.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tpContentRegexMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tpContentRegexMouseReleased(evt);
            }
        });
        tpContentRegex.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tpContentRegexKeyReleased(evt);
            }
        });
        jScrollPane5.setViewportView(tpContentRegex);

        lbWarning.setForeground(new java.awt.Color(255, 0, 0));
        lbWarning.setText("*Chưa nhập biểu thức chính quy");

        jLabel14.setText("Nhóm");

        cbNameAddRegex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbNameAddRegexActionPerformed(evt);
            }
        });

        btAddNameGroup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/down16.png"))); // NOI18N
        btAddNameGroup.setText("Thêm");
        btAddNameGroup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddNameGroupActionPerformed(evt);
            }
        });

        chbStatusRegex.setSelected(true);
        chbStatusRegex.setText("Kích hoạt");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbWarning, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(cbNameGroup, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btAddNameGroup)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                        .addComponent(chbStatusRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane5)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cbNameAddRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbTypeAddRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(cbTypeAddRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbNameAddRegex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbNameGroup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(btAddNameGroup)
                    .addComponent(chbStatusRegex))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbWarning)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel13.setText("Văn bản kiểm tra");

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        tpInputCheckText.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tpInputCheckTextKeyReleased(evt);
            }
        });
        jScrollPane6.setViewportView(tpInputCheckText);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        btAddRegex.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/add.png"))); // NOI18N
        btAddRegex.setText("Thêm mới");
        btAddRegex.setEnabled(false);
        btAddRegex.setInheritsPopupMenu(true);
        btAddRegex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddRegexActionPerformed(evt);
            }
        });

        btEditRegex.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/edit (2).png"))); // NOI18N
        btEditRegex.setText("Thay đổi    ");
        btEditRegex.setEnabled(false);
        btEditRegex.setInheritsPopupMenu(true);
        btEditRegex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEditRegexActionPerformed(evt);
            }
        });

        btListRegex.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/detail.png"))); // NOI18N
        btListRegex.setText("Danh sách");
        btListRegex.setInheritsPopupMenu(true);
        btListRegex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btListRegexActionPerformed(evt);
            }
        });

        btReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/refresh.png"))); // NOI18N
        btReset.setText("Làm mới   ");
        btReset.setInheritsPopupMenu(true);
        btReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btResetActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap(13, Short.MAX_VALUE)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btAddRegex, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btEditRegex, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btReset, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btListRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btAddRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btEditRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btReset, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btListRegex, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout panelRegexLayout = new javax.swing.GroupLayout(panelRegex);
        panelRegex.setLayout(panelRegexLayout);
        panelRegexLayout.setHorizontalGroup(
            panelRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRegexLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(panelRegexLayout.createSequentialGroup()
                        .addGroup(panelRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(12, 12, 12)
                        .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelRegexLayout.setVerticalGroup(
            panelRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRegexLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRegexLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panelParent.add(panelRegex, "cardRegex");

        jLabel15.setText("Địa chỉ");

        jPanel9.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        cbAddress.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbAddressItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbAddress, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btGetNames.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/send.png"))); // NOI18N
        btGetNames.setText("Lấy nhân vật");
        btGetNames.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btGetNamesActionPerformed(evt);
            }
        });

        jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        listCrawlerName.setModel(crawlerListModel);
        listCrawlerName.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                listCrawlerNameMousePressed(evt);
            }
        });
        jScrollPane7.setViewportView(listCrawlerName);

        tsCrawlerSearch.setForeground(java.awt.Color.gray);
        tsCrawlerSearch.setText("Tìm kiếm theo tên...");
        tsCrawlerSearch.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tsCrawlerSearchMousePressed(evt);
            }
        });
        tsCrawlerSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tsCrawlerSearchKeyReleased(evt);
            }
        });

        listChoseName.setModel(downloadListModel);
        listChoseName.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                listChoseNameMousePressed(evt);
            }
        });
        listChoseName.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listChoseNameValueChanged(evt);
            }
        });
        jScrollPane8.setViewportView(listChoseName);

        tfChoseSearch.setForeground(java.awt.Color.gray);
        tfChoseSearch.setText("Tìm kiếm theo tên...");
        tfChoseSearch.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tfChoseSearchMousePressed(evt);
            }
        });
        tfChoseSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfChoseSearchKeyReleased(evt);
            }
        });

        btRight.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/right.png"))); // NOI18N
        btRight.setEnabled(false);
        btRight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRightActionPerformed(evt);
            }
        });

        btLeft.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/left.png"))); // NOI18N
        btLeft.setEnabled(false);
        btLeft.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLeftActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(tsCrawlerSearch)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(btLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btRight, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfChoseSearch)
                    .addComponent(jScrollPane8))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tsCrawlerSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfChoseSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(btRight)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btLeft))
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jScrollPane8)
                .addGap(12, 12, 12))
        );

        jPanel10.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        tfPath.setText("Đường dẫn lưu....");

        btFolderChooser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/file.png"))); // NOI18N
        btFolderChooser.setText("Thư mục");
        btFolderChooser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btFolderChooserActionPerformed(evt);
            }
        });

        jLabel18.setText("Đường dẫn");

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tfPath, javax.swing.GroupLayout.PREFERRED_SIZE, 331, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btFolderChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btFolderChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));

        btDownloadFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/save.png"))); // NOI18N
        btDownloadFile.setText("Tải văn bản");
        btDownloadFile.setEnabled(false);
        btDownloadFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDownloadFileActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btDownloadFile)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btDownloadFile, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lbManageAddress.setForeground(java.awt.Color.blue);
        lbManageAddress.setText("Quản lý địa chỉ");
        lbManageAddress.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lbManageAddress.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                lbManageAddressMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                lbManageAddressMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                lbManageAddressMousePressed(evt);
            }
        });

        javax.swing.GroupLayout panelDownloadLayout = new javax.swing.GroupLayout(panelDownload);
        panelDownload.setLayout(panelDownloadLayout);
        panelDownloadLayout.setHorizontalGroup(
            panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDownloadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDownloadLayout.createSequentialGroup()
                        .addGroup(panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(panelDownloadLayout.createSequentialGroup()
                                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(panelDownloadLayout.createSequentialGroup()
                                .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lbManageAddress)))
                        .addContainerGap())
                    .addGroup(panelDownloadLayout.createSequentialGroup()
                        .addComponent(btGetNames)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        panelDownloadLayout.setVerticalGroup(
            panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDownloadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(lbManageAddress))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btGetNames, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelParent.add(panelDownload, "cardDownload");

        panelImageBackgroup.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTextPane1.setEditable(false);
        jTextPane1.setBackground(new java.awt.Color(255, 255, 204));
        jTextPane1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextPane1.setContentType("text/html"); // NOI18N
        jTextPane1.setText("<html>\r\n  <head>\r\n\r\n  </head>\r\n  <body>\r\n    <br /><div><font color=\"red\" size= \"6\" ><center><b>KHÓA LUẬN TỐT NGHIỆP</b></center></font></div><br />\n    <div><font size= \"4\" color=\"blue\" ><center><b><font>Đề tài: </font><font>Tìm hiểu rút trích thông tin và xây dựng công cụ <br />hỗ trợ trả lời câu hỏi về nhân vật lịch sử <br/>Việt Nam.</center></font></b></font></div><br /><br />\n<div style=\"margin-left:90px\"><b><font size= \"4\" color=\"#8B4726\">Giảng viên hướng dẫn:  </font></b></div>\n<div style=\"margin-left:160px\"><font size= \"4\" color=\"#8B4726\"><b>Ths. Đỗ Thị Thanh Tuyền</b></font></div><br />\n<div style=\"margin-left:100px\"><font size= \"4\" color=\"#8B4726\" ><b>Sinh viên thực hiện: </b></font></div>\n<div style=\"margin-left:130px\"><font size= \"4\" color=\"#8B4726\"><b>1. Phạm Trọng Nghĩa&nbsp&nbsp - &nbsp&nbsp 08520253 </b></font></div>\n<div style=\"margin-left:130px\"><font size= \"4\"  color=\"#8B4726\" ><b>2. Trần Quốc Công&nbsp&nbsp&nbsp&nbsp&nbsp - &nbsp&nbsp 08520046 </b></font></div>\n\n  </body>\r\n</html>\r\n");
        jTextPane1.setPreferredSize(new java.awt.Dimension(419, 102));
        jScrollPane9.setViewportView(jTextPane1);

        javax.swing.GroupLayout panelImageBackgroupLayout = new javax.swing.GroupLayout(panelImageBackgroup);
        panelImageBackgroup.setLayout(panelImageBackgroupLayout);
        panelImageBackgroupLayout.setHorizontalGroup(
            panelImageBackgroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImageBackgroupLayout.createSequentialGroup()
                .addContainerGap(176, Short.MAX_VALUE)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(154, 154, 154))
        );
        panelImageBackgroupLayout.setVerticalGroup(
            panelImageBackgroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelImageBackgroupLayout.createSequentialGroup()
                .addContainerGap(87, Short.MAX_VALUE)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(81, 81, 81))
        );

        javax.swing.GroupLayout panelAboutUsLayout = new javax.swing.GroupLayout(panelAboutUs);
        panelAboutUs.setLayout(panelAboutUsLayout);
        panelAboutUsLayout.setHorizontalGroup(
            panelAboutUsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAboutUsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelImageBackgroup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelAboutUsLayout.setVerticalGroup(
            panelAboutUsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAboutUsLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelImageBackgroup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        panelParent.add(panelAboutUs, "cardAboutUs");

        javax.swing.GroupLayout panelGeneralLayout = new javax.swing.GroupLayout(panelGeneral);
        panelGeneral.setLayout(panelGeneralLayout);
        panelGeneralLayout.setHorizontalGroup(
            panelGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelGeneralLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelParent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelGeneralLayout.setVerticalGroup(
            panelGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelGeneralLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelParent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        mnAnswer.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mnAnswer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/question48.png"))); // NOI18N
        mnAnswer.setText("Hỏi đáp tự động  ");
        mnAnswer.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        mnAnswer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnAnswerMousePressed(evt);
            }
        });
        mbarMain.add(mnAnswer);

        mnExtract.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mnExtract.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/extract48.png"))); // NOI18N
        mnExtract.setText("Rút trích thông tin  ");
        mnExtract.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        mnExtract.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnExtractMousePressed(evt);
            }
        });
        mbarMain.add(mnExtract);

        mnRegex.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mnRegex.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/Regex48.png"))); // NOI18N
        mnRegex.setText("Biểu thức chính quy  ");
        mnRegex.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        mnRegex.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnRegexMousePressed(evt);
            }
        });
        mbarMain.add(mnRegex);

        mnDownload.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mnDownload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/Download48.png"))); // NOI18N
        mnDownload.setText("Tải văn bản  ");
        mnDownload.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        mnDownload.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnDownloadMousePressed(evt);
            }
        });
        mbarMain.add(mnDownload);

        mnAboutUs.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mnAboutUs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/uit/ieproject/images/aboutus48.png"))); // NOI18N
        mnAboutUs.setText("Thông tin nhóm  ");
        mnAboutUs.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        mnAboutUs.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mnAboutUsMousePressed(evt);
            }
        });
        mbarMain.add(mnAboutUs);

        setJMenuBar(mbarMain);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelGeneral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelGeneral, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mnAnswerMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnAnswerMousePressed
        JMenu menu = (JMenu) evt.getSource();
        setStatusMenuClicked(menu, mnRegex, mnDownload, mnExtract, mnAboutUs);
        showCardItem(CARD_ANSWER_NAME, panelParent);
    }//GEN-LAST:event_mnAnswerMousePressed

    private void mnExtractMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnExtractMousePressed
        JMenu menu = (JMenu) evt.getSource();
        setStatusMenuClicked(menu, mnRegex, mnDownload, mnAnswer, mnAboutUs);
        showCardItem(CARD_EXTRACT_NAME, panelParent);
    }//GEN-LAST:event_mnExtractMousePressed

    private void mnRegexMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnRegexMousePressed
        JMenu menu = (JMenu) evt.getSource();
        setStatusMenuClicked(menu, mnExtract, mnDownload, mnAnswer, mnAboutUs);
        showCardItem(CARD_REGEX_NAME, panelParent);
    }//GEN-LAST:event_mnRegexMousePressed

    private void mnDownloadMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnDownloadMousePressed
        JMenu menu = (JMenu) evt.getSource();
        setStatusMenuClicked(menu, mnRegex, mnExtract, mnAnswer, mnAboutUs);
        showCardItem(CARD_DOWNLOAD_NAME, panelParent);
    }//GEN-LAST:event_mnDownloadMousePressed

    private void mnAboutUsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mnAboutUsMousePressed
        JMenu menu = (JMenu) evt.getSource();
        setStatusMenuClicked(menu, mnRegex, mnDownload, mnAnswer, mnExtract);
        showCardItem(CARD_ABOUTUS_NAME, panelParent);
    }//GEN-LAST:event_mnAboutUsMousePressed

    private void taQuestionKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_taQuestionKeyReleased
        JTextArea textarea = (JTextArea) evt.getSource();
        String input = textarea.getText().trim();
        if (!input.isEmpty()) {
            textarea.setForeground(Color.black);
            btAnswer.setEnabled(true);
        } else {
            textarea.setForeground(Color.gray);
            textarea.setText("Nhập câu hỏi vào đây...");
            textarea.selectAll();
            btAnswer.setEnabled(false);
        }
    }//GEN-LAST:event_taQuestionKeyReleased

    private void btAnswerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAnswerActionPerformed
        try {
            taAnswer.setText("");
            String question = taQuestion.getText();
            ArrayList<String> answers = ExtractUtil.getQuerySentencesFromQuestion(question);
            int numAnswers = answers.size();
            if (numAnswers > 0) {
                //Have the answer
                personNameAsk = answers.get(0);
                if (personBLO.checkPersonExists(personNameAsk) != 0) {
                    ImageUtil.showImage(lbImage, personNameAsk, IMG_WIDTH, IMG_HEIGHT, null);
                    btDetail.setEnabled(true);
                    for (int i = 1; i < numAnswers; i++) {
                        String answer = answers.get(i);
                        taAnswer.append(answer);
                        taAnswer.append("\n\n");
                    }
                } else {
                    taAnswer.append("Không tìm thấy tên nhân vật này trong hê thống!");
                    ImageUtil.showImage(lbImage, personNameAsk, IMG_WIDTH, IMG_HEIGHT, null);
                    btDetail.setEnabled(false);
                }
            } else {
                //Not annswer
                taAnswer.append("Hệ thống không hiểu câu hỏi!");
                btDetail.setEnabled(false);
                ImageUtil.showImage(lbImage, "default", IMG_WIDTH, IMG_HEIGHT, null);
            }
        } catch (SQLException ex) {
        }
    }//GEN-LAST:event_btAnswerActionPerformed

    private void btDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDetailActionPerformed
        try {
            new FullInfoPerson(personNameAsk).setVisible(true);
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_btDetailActionPerformed

    private void btChooseFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btChooseFilesActionPerformed
        ArrayList<File> filesSelected = FileUtil.getFiles("txt", true);
        int numSelectedFiles = filesSelected.size();
        if (numSelectedFiles > 0) {
            for (int i = 0; i < numSelectedFiles; i++) {
                fileListModel.addElement(filesSelected.get(i));
            }
            btExtract.setEnabled(true);
        }
    }//GEN-LAST:event_btChooseFilesActionPerformed

    private void btViewFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewFilesActionPerformed
        File selectedItem;
        int[] selected = listFiles.getSelectedIndices();
        int numSelectedFiles = selected.length;
        if (numSelectedFiles > 0) {
            for (int i = 0; i < numSelectedFiles; i++) {
                selectedItem = (File) listFiles.getModel().getElementAt(selected[i]);
                FileUtil.openFile(selectedItem);
            }
        }
    }//GEN-LAST:event_btViewFilesActionPerformed

    private void btDeleteFilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteFilesActionPerformed
        int[] selected = listFiles.getSelectedIndices();
        int numSelectedFiles = selected.length;
        if (numSelectedFiles > 0) {
            for (int i = numSelectedFiles - 1; i >= 0; i--) {
                fileListModel.remove(selected[i]);
            }
            if (fileListModel.isEmpty()) {
                btExtract.setEnabled(false);
            }
        }
        btDeleteFiles.setEnabled(false);
        btViewFiles.setEnabled(false);
    }//GEN-LAST:event_btDeleteFilesActionPerformed

    private void listFilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listFilesMousePressed
        int row = listFiles.getSelectedIndex();
        if (row < 0) {
            return;
        }
        if (evt.getClickCount() == 1) {
            btDeleteFiles.setEnabled(true);
            btViewFiles.setEnabled(true);
        } else {
            File selectedItem;
            selectedItem = (File) listFiles.getModel().getElementAt(row);
            FileUtil.openFile(selectedItem);
        }
    }//GEN-LAST:event_listFilesMousePressed

    private void tfSearchPersonKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfSearchPersonKeyReleased
        try {
            JTextField tf = (JTextField) evt.getSource();
            String keyword = tf.getText().trim();
            tf.setForeground(Color.black);
            ArrayList<Person> persons = personBLO.searchPersonByKeyword(keyword);
            showListPerson(persons);
            if (keyword.isEmpty()) {
                tf.setText("Tìm kiếm theo tên...");
                tf.setForeground(Color.gray);
                tf.selectAll();
            }
        } catch (SQLException ex) {
        }
    }//GEN-LAST:event_tfSearchPersonKeyReleased

    private void tfSearchPersonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tfSearchPersonMousePressed
        JTextField textfield = (JTextField) evt.getSource();
        textfield.selectAll();
    }//GEN-LAST:event_tfSearchPersonMousePressed

    private void tbExtractedPersonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbExtractedPersonMousePressed
        try {
            JTable list = (JTable) evt.getSource();
            int row = list.getSelectedRow();
            if (row < 0) {
                return;
            }
            if (evt.getClickCount() == 2) {
                Long id = Long.valueOf(list.getModel().getValueAt(row, 2).toString());
                Person person = personBLO.getPersonById(id).get(0);
                new DetailPersonFrame(person).setVisible(true);
            } else {
                btDeletePerson.setEnabled(true);
                btViewPerson.setEnabled(true);
            }
        } catch (SQLException ex) {
        }
    }//GEN-LAST:event_tbExtractedPersonMousePressed

    private void btViewPersonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btViewPersonActionPerformed
        try {
            long[] selectedIds = TableUtil.getIdsSelected(tbExtractedPerson, 2);
            int numSelectedPersons = selectedIds.length;
            if (numSelectedPersons > 0) {
                for (int i = 0; i < numSelectedPersons; i++) {
                    Person person = personBLO.getPersonById(selectedIds[i]).get(0);
                    new DetailPersonFrame(person).setVisible(true);
                }
            }
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_btViewPersonActionPerformed

    private void btDeletePersonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeletePersonActionPerformed
        try {
            int dialogResult = JOptionPane.showConfirmDialog(null, "Bạn có chắc chắn muốn xóa?", "Warning", JOptionPane.YES_NO_OPTION);
            if (dialogResult == JOptionPane.YES_OPTION) {
                DefaultTableModel model = (DefaultTableModel) tbExtractedPerson.getModel();
                File imageFile;
                File documentFile;
                long[] selectedIds = TableUtil.getIdsSelected(tbExtractedPerson, 2);
                int rowsSelected[] = tbExtractedPerson.getSelectedRows();
                int numSelectedPersons = rowsSelected.length;
                if (numSelectedPersons > 0) {
                    for (int i = numSelectedPersons - 1; i >= 0; i--) {
                        String name = (String) model.getValueAt(rowsSelected[i], 1);
                        imageFile = FileUtil.getCurrentDir(name, "jpg");
                        documentFile = FileUtil.getCurrentDir(name, "txt");
                        if (imageFile.exists()) {
                            imageFile.delete();
                        }

                        //Delete Document:
                        if (documentFile.exists()) {
                            documentFile.delete();
                        }

                        model.removeRow(rowsSelected[i]);
                    }
                    TableUtil.resetSeq(model);
                    personBLO.deletePersons(selectedIds);
                }
            }
        } catch (SQLException | IOException ex) {
        } finally {
            btDeletePerson.setEnabled(false);
            btViewPerson.setEnabled(false);
        }
    }//GEN-LAST:event_btDeletePersonActionPerformed

    private void cbTypeAddRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTypeAddRegexActionPerformed
        if (idSelectedRegex == 0) { //Add mode
            JComboBox cb = (JComboBox) evt.getSource();
            showCbNameRegex(cbNameAddRegex, cb);
            showGroupName(cbNameGroup, cb, cbNameAddRegex);
            btAddNameGroup.setEnabled(true);
            tpContentRegex.setText("");
            selectedGroups.clear();
        }
    }//GEN-LAST:event_cbTypeAddRegexActionPerformed

    private void cbNameAddRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbNameAddRegexActionPerformed
        if (idSelectedRegex == 0) { //Add mode
            JComboBox cb = (JComboBox) evt.getSource();
            showGroupName(cbNameGroup, cbTypeAddRegex, cb);
            btAddNameGroup.setEnabled(true);
            tpContentRegex.setText("");
            selectedGroups.clear();
        }
    }//GEN-LAST:event_cbNameAddRegexActionPerformed

    private void btAddNameGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddNameGroupActionPerformed
        String selected = (String) cbNameGroup.getSelectedItem();
        String input = "(?<" + selected + ">)";

        selectedGroups.add(selected);
        cbNameGroup.removeItem(selected);

        //Check if select text in textarea or not:
        if (tpContentRegex.getSelectedText() == null) {
            tpContentRegex.replaceSelection(input);
        } else {
            String selectedRegex = tpContentRegex.getSelectedText();
            String groupRegex = "(?<" + selected + ">" + selectedRegex + ")";
            tpContentRegex.replaceSelection(groupRegex);
        }
        String newInput = tpContentRegex.getText();
        checkInputRegex(newInput, cbNameGroup, lbWarning);
        previousValidRegex = newInput;
        TextpaneUtil.setForegroundForTextpane(tpContentRegex, Color.blue);
    }//GEN-LAST:event_btAddNameGroupActionPerformed

    private void tpContentRegexKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tpContentRegexKeyReleased
        // TODO add your handling code here:
        try {
            JTextPane textpane = (JTextPane) evt.getSource();
            Document doc = textpane.getDocument();
            String regex = doc.getText(0, doc.getLength());
            //String regex = textpane.getText().trim();


            //Check syntax for right color:
            if (isValidRegex(regex)) {
                TextpaneUtil.setForegroundForTextpane(textpane, Color.blue);
            } else {
                TextpaneUtil.setForegroundForTextpane(textpane, Color.red);
            }

            //Check input equal existed group:
            ArrayList<String> groups = getGroupsCanDeleteWhenSelect(cbNameGroup, regex);
            if (groups != null) {
                for (int i = 0; i < groups.size(); i++) {
                    String group = groups.get(i);
                    selectedGroups.add(group);
                    cbNameGroup.removeItem(group);
                    if (cbNameGroup.getItemCount() == 0) {
                        btAddNameGroup.setEnabled(false);
                    }
                }
            }

            //Check if can delete selected group
            if (selectedTextRegex != null && canDeleteRegex) {
                String deleteGroup = getValidDeleteGroupName(selectedTextRegex, selectedGroups);
                String regexInside = getContentInsideGroup(selectedTextRegex);
                if (regexInside != null) {
                    textpane.replaceSelection(regexInside);
                    previousValidRegex = textpane.getText();
                    cbNameGroup.addItem(deleteGroup);
                    selectedGroups.remove(deleteGroup);
                    setStatusEditAddRegexButton(false);
                    previousCaret = tpContentRegex.getCaretPosition();
                    selectedTextRegex = null;
                    canDeleteRegex = false;
                }
            }

            //Check some conditions
            checkInputRegex(regex, cbNameGroup, lbWarning);

            //Check invalid delete:
            if (!checkValidNumOfSelectedGroup(regex, selectedGroups) && !canDeleteRegex) {

                Toolkit.getDefaultToolkit().beep();
                textpane.setText(previousValidRegex);
                textpane.setCaretPosition(previousCaret);
                setWarningText(lbWarning, "*Xóa nhóm yêu cầu thất bại", Color.red);
                if (isValidRegex(previousValidRegex)) {
                    TextpaneUtil.setForegroundForTextpane(textpane, Color.blue);
                } else {
                    TextpaneUtil.setForegroundForTextpane(textpane, Color.red);
                }
            }

            //set Attribute for selected Text by keyboard:
            String selectedText = textpane.getSelectedText();
            TextpaneUtil.removeAllAtrributes(tpInputCheckText);
            if (selectedText != null && isValidRegex(selectedText)) {
                int start = textpane.getSelectionStart();
                int end = textpane.getSelectionEnd();
                setAttrForExistHili(regex, start, end, tpInputCheckText, Color.yellow);
            }


            //regex = textpane.getText();
            regex = doc.getText(0, doc.getLength());
            //remove all highlighters and update Highlighter       
            Highlighter highlighter = tpInputCheckText.getHighlighter();
            highlighter.removeAllHighlights();
            if (!regex.isEmpty() && isValidRegex(regex)) {
                TextpaneUtil.setHighlighterForCheckInput(regex, tpInputCheckText, Color.lightGray);
            }

            previousValidRegex = regex;
            previousCaret = textpane.getCaretPosition();
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_tpContentRegexKeyReleased

    private void tpContentRegexMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tpContentRegexMouseClicked
        JTextPane textpane = (JTextPane) evt.getSource();
        String regex = textpane.getText().trim();
        if (evt.getClickCount() == 2) {
            Point pt = new Point(evt.getX(), evt.getY());
            int pos = textpane.viewToModel(pt);
            int[] location = checkMousePositionAtGroup(pos, regex, selectedGroups);
            if (location != null) {
                int left = location[0];
                int right = location[1];
                textpane.setCaretPosition(right);
                textpane.select(left, right);
                selectedTextRegex = textpane.getSelectedText();
                canDeleteRegex = true;
                int start = textpane.getSelectionStart();
                int end = textpane.getSelectionEnd();
                //set highlighter for selected regex  
                setAttrForExistHili(regex, start, end, tpInputCheckText, Color.yellow);

            }
        }
    }//GEN-LAST:event_tpContentRegexMouseClicked

    private void tpContentRegexMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tpContentRegexMouseReleased
        JTextPane textpane = (JTextPane) evt.getSource();
        previousCaret = textpane.getCaretPosition();
        String selectedText = textpane.getSelectedText();
        selectedTextRegex = selectedText;

        //set highlighter for selected regex  
        TextpaneUtil.removeAllAtrributes(tpInputCheckText);
        if (selectedText != null && isValidRegex(selectedText)) {
            int start = textpane.getSelectionStart();
            int end = textpane.getSelectionEnd();
            String regex = textpane.getText().trim();
            setAttrForExistHili(regex, start, end, tpInputCheckText, Color.yellow);
        }

        if (selectedTextRegex != null) {
            if (getValidDeleteGroupName(selectedTextRegex, selectedGroups) != null) {
                canDeleteRegex = true;
            } else {
                canDeleteRegex = false;
            }
        }

        //group prediction
        if (cbNameGroup.getItemCount() > 0) {
            String selectedGroup = (String) cbNameGroup.getSelectedItem();
            String tempGroup = null;
            int start = textpane.getSelectionStart();
            int end = textpane.getSelectionEnd();
            if (selectedText != null) {
                if (isValidRegex(selectedText)) {
                    tempGroup = "(?<" + selectedGroup + ">" + selectedText + ")";
                } else {
                    btAddNameGroup.setEnabled(false);
                }
            } else {
                tempGroup = "(?<" + selectedGroup + ">)";
            }
            String nextRegex = textpane.getText();
            nextRegex = nextRegex.substring(0, start) + tempGroup + nextRegex.substring(end, nextRegex.length());
            ArrayList<String> nextSelectedGroup = new ArrayList<>(selectedGroups);
            nextSelectedGroup.add(selectedGroup);
            if (isValidRegex(nextRegex) && checkValidNumOfSelectedGroup(nextRegex, nextSelectedGroup)) {
                btAddNameGroup.setEnabled(true);
            } else {
                btAddNameGroup.setEnabled(false);
            }
        } else {
            btAddNameGroup.setEnabled(false);
        }
    }//GEN-LAST:event_tpContentRegexMouseReleased

    private void tpInputCheckTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tpInputCheckTextKeyReleased
        String regex = tpContentRegex.getText().trim();

        TextpaneUtil.removeAllAtrributes(tpInputCheckText);

        Highlighter highlighter = tpInputCheckText.getHighlighter();
        highlighter.removeAllHighlights();
        if (!regex.isEmpty() && isValidRegex(regex)) {
            TextpaneUtil.setHighlighterForCheckInput(regex, tpInputCheckText, Color.lightGray);
        }
    }//GEN-LAST:event_tpInputCheckTextKeyReleased

    private void cbAddressItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbAddressItemStateChanged
        if (cbAddress.getModel().getSize() > 0) {
            btGetNames.setEnabled(true);
        } else {
            btGetNames.setEnabled(false);
        }
    }//GEN-LAST:event_cbAddressItemStateChanged

    private void btGetNamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btGetNamesActionPerformed
        try {
            URL = cbAddress.getSelectedItem().toString();
            System.out.println(URL);
            map.clear();
            crawlerListModel.removeAllElements();
            crawlerNameButton.setEnabled(false);
            NameControllerThread nameRunnable = new NameControllerThread();
            downloadFileThread = new Thread(nameRunnable, "Download Thread");
            downloadFileThread.start();
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_btGetNamesActionPerformed

    private void tsCrawlerSearchMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tsCrawlerSearchMousePressed
        JTextField textfield = (JTextField) evt.getSource();
        textfield.selectAll();
    }//GEN-LAST:event_tsCrawlerSearchMousePressed

    private void tfChoseSearchMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tfChoseSearchMousePressed
        JTextField textfield = (JTextField) evt.getSource();
        textfield.selectAll();
    }//GEN-LAST:event_tfChoseSearchMousePressed

    private void tsCrawlerSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tsCrawlerSearchKeyReleased
        try {
            JTextField tf = (JTextField) evt.getSource();
            String keyword = tf.getText().trim();
            tf.setForeground(Color.black);
            searchList(keyword, listCrawlerName);
            if (keyword.isEmpty()) {
                tf.setForeground(Color.gray);
                tf.setText("Tìm kiếm theo tên...");
                tf.selectAll();
            }
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_tsCrawlerSearchKeyReleased

    private void tfChoseSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfChoseSearchKeyReleased
        try {
            JTextField tf = (JTextField) evt.getSource();
            String keyword = tf.getText().trim();
            tf.setForeground(Color.black);
            searchList(keyword, listChoseName);
            if (keyword.isEmpty()) {
                tf.setForeground(Color.gray);
                tf.setText("Tìm kiếm theo tên...");
                tf.selectAll();
            }
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_tfChoseSearchKeyReleased

    private void listCrawlerNameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listCrawlerNameMousePressed
        JList list = (JList) evt.getSource();
        int index = list.locationToIndex(evt.getPoint());
        if (index < 0) {
            return;
        }
        btRight.setEnabled(true);
        btLeft.setEnabled(false);
    }//GEN-LAST:event_listCrawlerNameMousePressed

    private void listChoseNameValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listChoseNameValueChanged
        if (listChoseName.getModel().getSize() > 0 && !directory.substring(0, directory.length() - 1).equals("null")) {
            btDownloadFile.setEnabled(true);
        } else {
            btDownloadFile.setEnabled(false);
        }
    }//GEN-LAST:event_listChoseNameValueChanged

    private void listChoseNameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listChoseNameMousePressed
        JList list = (JList) evt.getSource();
        int index = list.locationToIndex(evt.getPoint());
        if (index < 0) {
            return;
        }
        btRight.setEnabled(false);
        btLeft.setEnabled(true);
    }//GEN-LAST:event_listChoseNameMousePressed

    private void btRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRightActionPerformed
        String selectedItem;
        int[] selected = listCrawlerName.getSelectedIndices();
        int numSelectedItems = selected.length;
        for (int i = numSelectedItems - 1; i >= 0; i--) {
            selectedItem = (String) crawlerListModel.getElementAt(selected[i]);
            crawlerListModel.removeElement(selectedItem);
            downloadListModel.addElement(selectedItem);
        }
        btRight.setEnabled(false);
    }//GEN-LAST:event_btRightActionPerformed

    private void btLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLeftActionPerformed
        String selectedItem;
        int[] selected = listChoseName.getSelectedIndices();
        int numSelectedItems = selected.length;
        for (int i = numSelectedItems - 1; i >= 0; i--) {
            selectedItem = (String) downloadListModel.getElementAt(selected[i]);
            downloadListModel.removeElement(selectedItem);
            crawlerListModel.addElement(selectedItem);
        }
        btLeft.setEnabled(false);
    }//GEN-LAST:event_btLeftActionPerformed

    private void btFolderChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFolderChooserActionPerformed
        directory = FileUtil.promptForFolder(this);
        if (directory != null) {
            directory += "\\";
            if (listChoseName.getModel().getSize() > 0 && !directory.substring(0, directory.length() - 1).equals("null")) {
                btDownloadFile.setEnabled(true);
            } else {
                btDownloadFile.setEnabled(false);
            }
            tfPath.setText(directory);
        }
    }//GEN-LAST:event_btFolderChooserActionPerformed

    private void btDownloadFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDownloadFileActionPerformed
        try {
            // TODO add your handling code here:
            btDownloadFile.setEnabled(false);
            ArrayList<String> infos = addressBLO.getInfoFromAddress(cbAddress.getSelectedItem().toString());
            title = infos.get(0);
            paragraph = infos.get(1);
            image = infos.get(2);
            String selectedItem;
            int size = listChoseName.getModel().getSize();
            ArrayList<String> link = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                selectedItem = (String) listChoseName.getModel().getElementAt(i);
                link.add(MainFrame.map.get(selectedItem));
            }
            MyControllerThread myRunnable = new MyControllerThread(link);
            crawlerThread = new Thread(myRunnable, "Crawler Thread");
            crawlerThread.start();
        } catch (SQLException ex) {
        }
    }//GEN-LAST:event_btDownloadFileActionPerformed

    private void btExtractActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExtractActionPerformed
        //Reset Status:
        tpStatus.setText("");
        pbStatus.setValue(0);
        DefaultTableModel personsModel = (DefaultTableModel) tbExtractedPerson.getModel();

        int dialogResult = JOptionPane.showConfirmDialog(
                null, "Tiến hành rút trích?", "Warning", JOptionPane.YES_NO_OPTION);
        if (dialogResult == JOptionPane.YES_OPTION) {
            rbStatus.setSelected(true);
            showCardItem(CARD_STATUS_NAME, panelCard);

            ExtractionThread extractRunnable = new ExtractionThread(
                    pbStatus, tpStatus, personsModel, btExtract, btChooseFiles, btViewFiles, btDeleteFiles, fileListModel, lbExtractImg, lbExtractName);
            extractThread = new Thread(extractRunnable, "Extraction");
            extractThread.start();

        }

    }//GEN-LAST:event_btExtractActionPerformed

    private void btAddRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddRegexActionPerformed
        try {
            Regex regex = new Regex();
            regex.setName(cbNameAddRegex.getSelectedItem().toString());
            regex.setType(cbTypeAddRegex.getSelectedItem().toString());
            regex.setExpression(tpContentRegex.getText().trim());
            if (chbStatusRegex.isSelected()) {
                regex.setIsActive(1);
            } else {
                regex.setIsActive(0);
            }
            regexBLO.addRegex(regex);
            setWarningText(lbWarning, "Thêm biểu thức chính quy thành công", Color.blue);
            resetPanelRegex();
        } catch (SQLException ex) {
            setWarningText(lbWarning, "Thêm biểu thức chính quy thất bại", Color.blue);
        }
    }//GEN-LAST:event_btAddRegexActionPerformed

    private void btEditRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEditRegexActionPerformed
        try {
            Regex regex = new Regex();
            regex.setId(idSelectedRegex);
            regex.setName(cbNameAddRegex.getSelectedItem().toString());
            regex.setType(cbTypeAddRegex.getSelectedItem().toString());
            regex.setExpression(tpContentRegex.getText().trim());
            if (chbStatusRegex.isSelected()) {
                regex.setIsActive(1);
            } else {
                regex.setIsActive(0);
            }
            regexBLO.editRegex(regex);
            setWarningText(lbWarning, "Thay đổi biểu thức chính quy thành công", Color.blue);
            resetPanelRegex();
        } catch (SQLException ex) {
            setWarningText(lbWarning, "Thay đổi biểu thức chính quy thất bại", Color.blue);
        }
    }//GEN-LAST:event_btEditRegexActionPerformed

    private void btResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btResetActionPerformed
        resetPanelRegex();
    }//GEN-LAST:event_btResetActionPerformed

    private void btListRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btListRegexActionPerformed
        new ListRegexFrame().setVisible(true);
    }//GEN-LAST:event_btListRegexActionPerformed

    private void taQuestionMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_taQuestionMousePressed
        JTextArea textarea = (JTextArea) evt.getSource();
        textarea.selectAll();
    }//GEN-LAST:event_taQuestionMousePressed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if ((downloadFileThread != null && downloadFileThread.isAlive()) || (extractThread != null && extractThread.isAlive())) {
            String warning = "";
            if (downloadFileThread != null && downloadFileThread.isAlive()) {
                warning = "Tiến trình tải tập tin vẫn chưa kết thúc! Bạn có muốn thoát?";
            }
            if (extractThread != null && extractThread.isAlive()) {
                warning = "Tiến trình rút trích dữ liệu vẫn chưa kết thúc! Bạn có muốn thoát?";
            }
            int select = JOptionPane.showConfirmDialog(null, warning, "Chú ý", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null);
            if (select == JOptionPane.YES_OPTION) {
                System.exit(0);
            }
        } else {
            System.exit(0);
        }
    }//GEN-LAST:event_formWindowClosing

    private void rbStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbStatusActionPerformed
        showCardItem(CARD_STATUS_NAME, panelCard);
    }//GEN-LAST:event_rbStatusActionPerformed

    private void rbCreateFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbCreateFileActionPerformed
        showCardItem(CARD_CREATEFILE_NAME, panelCard);
    }//GEN-LAST:event_rbCreateFileActionPerformed

    private void lbDirStoreFileMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreFileMouseEntered
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.orange);
    }//GEN-LAST:event_lbDirStoreFileMouseEntered

    private void lbDirStoreFileMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreFileMouseExited
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.blue);
    }//GEN-LAST:event_lbDirStoreFileMouseExited

    private void lbDirStoreFileMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreFileMousePressed
        String dir = FileUtil.promptForFolder(this);
        if (dir != null) {
            dir += "\\";
            tfDirStoreFile.setText(dir);
            tfDirStoreFile.setForeground(Color.black);
            if (contentAddedFile != null) {
                btFileAdd.setEnabled(true);
            }
        }
    }//GEN-LAST:event_lbDirStoreFileMousePressed

    private void lbDirStoreImgMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreImgMouseEntered
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.orange);
    }//GEN-LAST:event_lbDirStoreImgMouseEntered

    private void lbDirStoreImgMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreImgMouseExited
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.blue);
    }//GEN-LAST:event_lbDirStoreImgMouseExited

    private void lbDirStoreImgMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbDirStoreImgMousePressed
        ArrayList<File> choseFiles = FileUtil.getFiles("img", false);
        if (choseFiles.size() > 0) {
            File imgFile = choseFiles.get(0);
            tfDirStoreImg.setForeground(Color.black);
            tfDirStoreImg.setText(imgFile.getAbsolutePath());
        }
    }//GEN-LAST:event_lbDirStoreImgMousePressed

    private void btFileContentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileContentActionPerformed
        if (tfDirStoreImg.getForeground() != Color.gray) {
            urlImageAddedFile = tfDirStoreImg.getText().trim();
            typeImgString = checkImgStrIsDirOrUrl(urlImageAddedFile);
        }
        new ContentFileFrame(contentAddedFile, typeImgString, urlImageAddedFile).setVisible(true);
    }//GEN-LAST:event_btFileContentActionPerformed

    private void btFileResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileResetActionPerformed
        resetPanelAddFile();
    }//GEN-LAST:event_btFileResetActionPerformed

    private void btFileAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFileAddActionPerformed
        ArrayList<String> content = new ArrayList<>();
        contentAddedFile = PennTokenizer.tokenize(contentAddedFile);
        String[] paragraphs = contentAddedFile.split("\n");
        if (paragraphs.length > 0) {
            for (int i = 0; i < paragraphs[i].length(); i++) {
                paragraphs[i] = paragraphs[i].trim();
            }
            content.addAll(Arrays.asList(paragraphs));
            String dirStoreFile = tfDirStoreFile.getText();
            String urlImg = tfDirStoreImg.getText().trim();
            try {
                //Add text file:
                File file = FileUtil.saveTextToFile(dirStoreFile, nameAddedFile, "txt", content, false);
                fileListModel.addElement(file);

                //Add Img File:
                if (tfDirStoreImg.getForeground() != Color.gray) {
                    typeImgString = checkImgStrIsDirOrUrl(urlImg);
                    if (typeImgString == 0) {   //url
                        ImageUtil.saveImageFromWeb(urlImg, dirStoreFile, nameAddedFile, "jpg");
                    }
                    if (typeImgString == 1) {   //dir
                        String type = "jpg";
                        File imgFile = FileUtil.getImageFromPath(nameAddedFile, urlImg, type);
                        if (imgFile.exists()) {
                            FileUtil.saveFile(false, dirStoreFile, imgFile, nameAddedFile, type);
                        }
                    }
                }

                btExtract.setEnabled(true);
            } catch (IOException ex) {
            } finally {
                resetPanelAddFile();
            }
        }

    }//GEN-LAST:event_btFileAddActionPerformed

    private void tfDirStoreImgKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfDirStoreImgKeyReleased
        JTextField textfield = (JTextField) evt.getSource();
        String content = textfield.getText().trim();
        if (content.isEmpty()) {
            textfield.setText("Nhập đường dẫn hình ảnh...");
            textfield.setForeground(Color.gray);
            textfield.selectAll();
        } else {
            textfield.setForeground(Color.black);
        }
    }//GEN-LAST:event_tfDirStoreImgKeyReleased

    private void tfDirStoreImgMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tfDirStoreImgMousePressed
        JTextField textfield = (JTextField) evt.getSource();
        if (textfield.getForeground() == Color.gray || evt.getClickCount() == 2) {
            textfield.selectAll();
        }
    }//GEN-LAST:event_tfDirStoreImgMousePressed

    private void lbManageAddressMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbManageAddressMouseEntered
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.orange);
    }//GEN-LAST:event_lbManageAddressMouseEntered

    private void lbManageAddressMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbManageAddressMouseExited
        JLabel label = (JLabel) evt.getSource();
        label.setForeground(Color.blue);
    }//GEN-LAST:event_lbManageAddressMouseExited

    private void lbManageAddressMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lbManageAddressMousePressed
        new AddressFrame().setVisible(true);
    }//GEN-LAST:event_lbManageAddressMousePressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAddNameGroup;
    private javax.swing.JButton btAddRegex;
    private javax.swing.JButton btAnswer;
    private javax.swing.JButton btChooseFiles;
    private javax.swing.JButton btDeleteFiles;
    private javax.swing.JButton btDeletePerson;
    private javax.swing.JButton btDetail;
    private javax.swing.JButton btDownloadFile;
    private javax.swing.JButton btEditRegex;
    private javax.swing.JButton btExtract;
    public javax.swing.JButton btFileAdd;
    private javax.swing.JButton btFileContent;
    private javax.swing.JButton btFileReset;
    private javax.swing.JButton btFolderChooser;
    private javax.swing.JButton btGetNames;
    private javax.swing.JButton btLeft;
    private javax.swing.JButton btListRegex;
    private javax.swing.JButton btReset;
    private javax.swing.JButton btRight;
    private javax.swing.JButton btViewFiles;
    private javax.swing.JButton btViewPerson;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbAddress;
    private javax.swing.JComboBox cbNameAddRegex;
    private javax.swing.JComboBox cbNameGroup;
    private javax.swing.JComboBox cbTypeAddRegex;
    private javax.swing.JCheckBox chbStatusRegex;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTextPane jTextPane1;
    public javax.swing.JLabel lbAddFileWarning;
    private javax.swing.JLabel lbDirStoreFile;
    private javax.swing.JLabel lbDirStoreImg;
    private javax.swing.JLabel lbExtractImg;
    private javax.swing.JLabel lbExtractName;
    private javax.swing.JLabel lbImage;
    private javax.swing.JLabel lbManageAddress;
    private javax.swing.JLabel lbWarning;
    private javax.swing.JList listChoseName;
    private javax.swing.JList listCrawlerName;
    private javax.swing.JList listFiles;
    private javax.swing.JMenuBar mbarMain;
    private javax.swing.JMenu mnAboutUs;
    private javax.swing.JMenu mnAnswer;
    private javax.swing.JMenu mnDownload;
    private javax.swing.JMenu mnExtract;
    private javax.swing.JMenu mnRegex;
    private javax.swing.JPanel panelAboutUs;
    private javax.swing.JPanel panelAnswer;
    private javax.swing.JPanel panelCard;
    private javax.swing.JPanel panelCreateFile;
    private javax.swing.JPanel panelDownload;
    private javax.swing.JPanel panelExtract;
    private javax.swing.JPanel panelGeneral;
    private javax.swing.JPanel panelImageBackgroup;
    private javax.swing.JPanel panelParent;
    private javax.swing.JPanel panelRegex;
    private javax.swing.JPanel panelStatus;
    private javax.swing.JProgressBar pbStatus;
    private javax.swing.JRadioButton rbCreateFile;
    private javax.swing.JRadioButton rbStatus;
    private javax.swing.JTextArea taAnswer;
    private javax.swing.JTextArea taQuestion;
    private javax.swing.JTable tbExtractedPerson;
    private javax.swing.JTextField tfChoseSearch;
    public javax.swing.JTextField tfDirStoreFile;
    private javax.swing.JTextField tfDirStoreImg;
    private javax.swing.JTextField tfPath;
    private javax.swing.JTextField tfSearchPerson;
    private javax.swing.JTextPane tpContentRegex;
    private javax.swing.JTextPane tpInputCheckText;
    private javax.swing.JTextPane tpStatus;
    private javax.swing.JTextField tsCrawlerSearch;
    // End of variables declaration//GEN-END:variables
}
